package pers.wensheng.patterns.behavioral_pattern.visitor_pattern.extend.dynamic_dispatch;

class Animal {
    public void execute() {
        System.out.println("Animal");
    }
}

class Dog extends Animal {
    @Override
    public void execute() {
        System.out.println("dog");
    }
}

class Cat extends Animal {
     @Override
    public void execute() {
        System.out.println("cat");
    }
}

/**
 * 动态分派
 */
public class Client {
   	public static void main(String[] args) {
        Animal a = new Dog();
        a.execute();

        Animal a1 = new Cat();
        a1.execute();
    }
}
